package org.microservice.system.utils.dto;

import lombok.Data;
import org.apache.commons.beanutils.BeanUtils;
import org.microservice.common.bean.MenuVo;
import org.microservice.common.util.TreeNode;

import java.lang.reflect.InvocationTargetException;

/**
 * @author lengleng
 * @date 2017年11月9日23:33:27
 */
@Data
public class MenuTree extends TreeNode {
    private String icon;
    private String name;
    private String path;
    private String component;
    private String perms;
    private String redirect;
    private boolean enabledCache;
    private int type;
    private String orderNum;
    private boolean disabled;
    private String createdBy;
    private String createdTime;
    private String lastModifiedBy;
    private String lastModifiedTime;
    public MenuTree() {
    }

    public MenuTree(int id, String name, int parentId) {
        this.id = id;
        this.parentId = parentId;
        this.name = name;
    }

    public MenuTree(int id, String name, MenuTree parent) {
        this.id = id;
        this.parentId = parent.getId();
        this.name = name;
    }

    public MenuTree(MenuVo menuVo) {
       /* this.id = menuVo.getId();
        this.parentId = menuVo.getParentId();
        this.icon = menuVo.getIcon();
        this.name = menuVo.getName();
        this.path = menuVo.getPath();
        this.component = menuVo.getComponent();
        this.type = menuVo.getType();
        this.title = menuVo.getName();
        this.orderNum = menuVo.getOrderNum();
        this.disabled = menuVo.isDisabled();
        this.perms = menuVo.getPerms();*/
        try {
            BeanUtils.copyProperties(this,menuVo);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }

    }
}
